//1
//1 2 2 3 1 3
// 输入两行, 第一行是摇摇车的数量, 第二行是小朋友的编号
// 有两个对列, 一个是正在玩的队列, 一个是等待队列
// 玩出对, 表示有个小朋友正常,
// 如果排队出队, 且没有合适的玩, 则不开心的小朋友+1
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let n;
let initArr = [];
rl.on("line", (line)=>{
    if(n === undefined) {
        n = Number(line.trim())
    } else {
        initArr = line.trim().split(/\s+/).map(Number)
        console.log(getResult(n, initArr))
        // clear
        n = undefined
        initArr.length = 0
    }

})

function getResult(n, initArr) {
    let playingArr = []
    let playingCount = 0
    let waitingArr = []
    let unhappyCount = 0
    for (let i = 0; i < initArr.length; i++) {
        let num = initArr[i]

        let playingIndex = playingArr.indexOf(num) // 是否已经在玩
        let waitingIndex = waitingArr.indexOf(num) // 是否已经在排队

        // 直接玩
        if(playingIndex === -1 && waitingIndex === -1 && playingCount < n) {
            playingArr.push(num)
            playingCount++
            continue
        }

        //排队
        if(playingIndex === -1 && waitingIndex === -1 && playingCount === n ) {
            waitingArr.push(num)
            continue
        }

        // 玩结束离开
        if(playingIndex !== -1){
            playingArr.splice(playingIndex, 1)
            if(waitingArr.length) {
                playingArr.push(waitingArr.shift())
            } else {
                playingCount--
            }

            continue
        }

        //排队中离开
        if(waitingIndex !== -1) {
            waitingArr.splice(waitingIndex, 1)
            unhappyCount++
        }
    }
    return unhappyCount
}